import time

from selenium import webdriver
from selenium.webdriver.common.by import By


class BaseTest:
    def setup_method(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(5)
        self.driver.maximize_window()
    def teardown_method(self):
        self.driver.quit()

    def login(self):
        self.driver.get("https://litemall.hogwarts.ceshiren.com/#/login")
        login_button = (By.CSS_SELECTOR, ".login-container>form>button")
        product_ma = (By.CSS_SELECTOR, '.el-scrollbar__view>.el-menu>div:nth-child(3)')
        product_list = (By.XPATH, '//*[text()="商品列表"]/../..')
        self.driver.find_element(*login_button).click()
        self.driver.find_element(*product_ma).click()  # 点击主菜单
        self.driver.find_element(*product_list).click()  # 点击子菜单
        time.sleep(3)
